package com.dxq.test.db;

import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;

/**
 * Author: zsh
 * Date: 2023/10/19
 * Describe: 牧场表（字段）
 */
@DatabaseTable(tableName = "Pasture")
public class Pasture implements Serializable {

    public final static String ID_FIELD_NAME = "pasture_id";

    // id = true:表明这个字段是这条记录的唯一标志符, generatedId = true:表明自动增加的ID
    //序号
    @DatabaseField(generatedId = true, columnName = ID_FIELD_NAME)
    private int pasture_id;

    //牧场名称
    @DatabaseField(columnName = "name")
    private String name;

    //养殖品种
    @DatabaseField(columnName = "type")
    private String type;

    //牧场介绍
    @DatabaseField(columnName = "info")
    private String info;

    //创建时间
    @DatabaseField(columnName = "create_time")
    private String create_time;

    //修改时间
    @DatabaseField(columnName = "update_time")
    private String update_time;

    //ForeignCollectionField:一对多管理，表示一个pasture对应多个label
    @ForeignCollectionField(eager = false)
    private ForeignCollection<Label> labels;

    //ForeignCollectionField:一对多管理，表示一个pasture对应多个group
    @ForeignCollectionField(eager = false)
    private ForeignCollection<Group> groups;

    //ForeignCollectionField:一对多管理，表示一个pasture对应多个breed
    @ForeignCollectionField(eager = false)
    private ForeignCollection<Breed> breeds;

    //ForeignCollectionField:一对多管理，表示一个pasture对应多个vaccine
    @ForeignCollectionField(eager = false)
    private ForeignCollection<Vaccine> vaccines;

    //ForeignCollectionField:一对多管理，表示一个pasture对应多个food
    @ForeignCollectionField(eager = false)
    private ForeignCollection<Food> foods;

    //ForeignCollectionField:一对多管理，表示一个pasture对应多个feed
    @ForeignCollectionField(eager = false)
    private ForeignCollection<Feed> feeds;

    //ForeignCollectionField:一对多管理，表示一个pasture对应多个event
    @ForeignCollectionField(eager = false)
    private ForeignCollection<Event> events;

    @DatabaseField(persisted = false)//如果设置为false，表示这个字段不会写到数据库中
    private boolean isCheck;//是否选中

    public Pasture() {
    }

    public Pasture(String name, String type, String info, String create_time, String update_time, ForeignCollection<Label> labels) {
        this.name = name;
        this.type = type;
        this.info = info;
        this.create_time = create_time;
        this.update_time = update_time;
        this.labels = labels;
    }

    public int getPasture_id() {
        return pasture_id;
    }

    public void setPasture_id(int pasture_id) {
        this.pasture_id = pasture_id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(String update_time) {
        this.update_time = update_time;
    }

    public ForeignCollection<Label> getLabels() {
        return labels;
    }

    public void setLabels(ForeignCollection<Label> labels) {
        this.labels = labels;
    }

    public ForeignCollection<Group> getGroups() {
        return groups;
    }

    public void setGroups(ForeignCollection<Group> groups) {
        this.groups = groups;
    }

    public ForeignCollection<Breed> getBreeds() {
        return breeds;
    }

    public void setBreeds(ForeignCollection<Breed> breeds) {
        this.breeds = breeds;
    }

    public ForeignCollection<Vaccine> getVaccines() {
        return vaccines;
    }

    public void setVaccines(ForeignCollection<Vaccine> vaccines) {
        this.vaccines = vaccines;
    }

    public ForeignCollection<Food> getFoods() {
        return foods;
    }

    public void setFoods(ForeignCollection<Food> foods) {
        this.foods = foods;
    }

    public ForeignCollection<Feed> getFeeds() {
        return feeds;
    }

    public void setFeeds(ForeignCollection<Feed> feeds) {
        this.feeds = feeds;
    }

    public ForeignCollection<Event> getEvents() {
        return events;
    }

    public void setEvents(ForeignCollection<Event> events) {
        this.events = events;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    @Override
    public String toString() {
        return "Pasture{" +
                "pasture_id=" + pasture_id +
                ", name='" + name + '\'' +
                ", type='" + type + '\'' +
                ", info='" + info + '\'' +
                ", create_time='" + create_time + '\'' +
                ", update_time='" + update_time + '\'' +
                ", labels=" + labels +
                ", groups=" + groups +
                ", breeds=" + breeds +
                ", vaccines=" + vaccines +
                ", foods=" + foods +
                ", feeds=" + feeds +
                ", events=" + events +
                '}';
    }
}
